package session07.homework;

import javax.swing.*;
import java.awt.*;

public class MyFrame extends JFrame {

    private Container contentP;

    private TopPanel topP;
    private MiddlePanel midP;
    private BottomPanel botP;

    public MyFrame() {
        this.setSize(338, 587);
        this.setTitle("QQ200X");
        Toolkit tk = Toolkit.getDefaultToolkit();
        this.setIconImage(tk.createImage("img/logo.gif"));
        this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);//传另一个容器就相对于另一个容器，传null就相对于屏幕
        this.setResizable(false);//设置窗体大小不可变

        this.addContent();

        this.setVisible(true);
    }

    private void addContent() {
        this.contentP = this.getContentPane();//获取内容面板
        this.contentP.setLayout(null);

        this.topP = new TopPanel(this);
        this.topP.setBounds(0,0,338, 221);
        this.midP = new MiddlePanel();
        this.midP.setBounds(0,221,338, 91);
        this.botP = new BottomPanel();
        this.botP.setBounds(0,312,338,240);

        this.contentP.add(this.topP);
        this.contentP.add(this.midP);
        this.contentP.add(this.botP);
    }
}
